package com.nbjtjc.safe.activiti.api;

import com.nbjtjc.safe.activiti.model.ActivitiParams;
import com.nbjtjc.safe.activiti.service.DangerFlowService;
import com.nbjtjc.safe.annotation.ReassignTaskCheck;
import com.nbjtjc.safe.bean.Page;
import com.nbjtjc.safe.bean.Result;
import com.nbjtjc.safe.model.danger.DangerInspectPublic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @auther guqianbin
 * 隐患检查的工作刘接口
 * @date 2018/6/7 11:15
 **/
@RestController
@RequestMapping("/dangerFlow")
@CrossOrigin("*")
public class FlowDangerController {

    @Autowired
    private DangerFlowService dangerFlowService;

    @PostMapping("/startDangerFlow")
    public Result startDangerFlow(@RequestBody DangerInspectPublic dangerInspectPublic){
        Result result=new Result();
        result=dangerFlowService.startDangerFlow(dangerInspectPublic);
        return result;
    }
    @PostMapping("/startDangerFlowNoJson")
    public Result startDangerFlowNoJson(DangerInspectPublic dangerInspectPublic){
        Result result=new Result();
        result=dangerFlowService.startDangerFlow(dangerInspectPublic);
        return result;
    }

    @RequestMapping(value = "/doTask",method = {RequestMethod.POST,RequestMethod.GET})
    @ReassignTaskCheck
    public Result doTask(ActivitiParams params){
        Result result=new Result();
        result=dangerFlowService.doTask(params);
        return result;
    }

    @GetMapping("/getUndoTask")
    public Result getUndoTask(Page page,String taskDefineKey){
        Result result=new Result();
        result=dangerFlowService.getUndoTask(page,taskDefineKey);
        return result;
    }

    @GetMapping("/getHistoryTask")
    public Result getHistoryTask(Page page){
        Result result=new Result();
        result=dangerFlowService.getDangerHistoryTask(page);
        return result;
    }

    @GetMapping("/getHistoryTaskWithStatus")
    public Result getHistoryTaskWithStatus(Page page){
        Result result=new Result();
        result=dangerFlowService.getMyDoneTask(page);
        return result;
    }

    @GetMapping("/getRunningProcessInstance")
    public Result getRunningProcessInstance(Page page){
        Result result=new Result();
        result.setData(dangerFlowService.getRunningProcessInstance(page));
        return result;
    }

}
